﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class LibraryElement : FileElement
    {
        private List<ExportsElement> exports;
        private List<ISyntaxTreeElement> implementations;
        private CompoundStatementElement compound;

        public List<ISyntaxTreeElement> Implementations { get { return implementations; } set { implementations = value; } }
        public List<ExportsElement> Exports { get { return exports; } set { exports = value; } }
        public CompoundStatementElement Compound { get { return compound; } set { compound = value; } }

        public LibraryElement(TokenInfo StartInfo, string Path, IdElement Name, UsesElement Uses, List<ISyntaxTreeElement> Implementations, List<ExportsElement> Exports, CompoundStatementElement Compound, List<TokenInfo> Comments)
            : base(StartInfo, Path, Name, Uses, Comments)
        {
            implementations = Implementations;
            exports = Exports;
            compound = Compound;
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            IEnumerator<ISyntaxTreeElement> baseEnumerator = base.CreateEnumerator();
            while (baseEnumerator.MoveNext())
                yield return baseEnumerator.Current;
            if (implementations != null)
                foreach (ISyntaxTreeElement implementation in implementations)
                    yield return implementation;
            if (exports != null)
                foreach (ExportsElement export in exports)
                    yield return export;
            if (compound != null) yield return compound;
        }
    }
}
